/**
 * All rights Reserved, Designed By 信鸥科技
 * project : projectweb
 * Created by youquer on 17/9/30.
 * 注意：本内容仅限于信鸥科技有限公司内部传阅，禁止外泄以及用于其他的商业目的
 * Description: 多选树
 *
 */
import React from 'react';
import { Link } from 'dva/router';
import { connect } from 'dva';
import PropTypes from 'prop-types';

import { TreeSelect } from 'antd';
const SHOW_CHILD = TreeSelect.SHOW_CHILD;


const SelectMoreTree  = ({treeDates, value, dispatch, keyItems, type, routeItems, callBack}) =>{

  function onChange (value){
    var t = {};
    t[keyItems] = value;
    dispatch({
      type: type + '/changeState',
      key: keyItems,
      value: value
    });
    dispatch({
      type: type + '/singleTreeCallBack',
      payload: value,
      key: keyItems
    });
    if (routeItems != undefined && routeItems != ""){
      dispatch({
        type: type + routeItems,
        payload:{
          value: value
        }
      });
    }
    if (callBack){
      dispatch({
        type: type + callBack,
        payload: value,
        key: keyItems
      });
    }
  }

  const treeData = treeDates;
  const tProps = {
    treeData,
    value: value,

    treeCheckable: true,
    showCheckedStrategy: SHOW_CHILD,
    searchPlaceholder: '',
    treeNodeFilterProp: 'title',
    style: {
      width: '100%',
      height:'100%'
    },
    multiple:true
  };
  return(
    <TreeSelect onChange= {onChange} {...tProps} />
  )
};

//SelectMoreTree.propTypes = {
//  onChange: PropTypes.func.isRequired,
//};

export default connect()(SelectMoreTree);
